package com.idbk.chargestation.activity.assist;

import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.idbk.chargestation.R;
import com.idbk.chargestation.base.BaseActivity;

/**
 * 充电桩操作说明
 * @author lupc
 *
 */
public class ActivityHelp extends BaseActivity {

	public final static String HELP_URL = "file:///android_asset/help/index.html";

	private WebView mWebView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_help);

		setupView();

		setupData();
	} 

	private void setupView() {
		setupToolBar2();//显示标题栏
		mWebView = (WebView) findViewById(R.id.help_webview);
		if (mWebView != null) {
			mWebView.getSettings().setJavaScriptEnabled(false);
			mWebView.getSettings().setDefaultTextEncodingName("utf-8");
			mWebView.setWebViewClient(new WebViewClient() {
				@Override
				public boolean shouldOverrideUrlLoading(WebView view, String url)
				{
					view.loadUrl(url);
					return true;
				}
			});
		}
	}

	private void setupData() {
		mWebView.loadUrl(HELP_URL);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()){
			mWebView.goBack();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

}
